package easy

func PivotIndex(nums []int) int {
	sum := 0
	for _, v := range nums {
		sum += v
	}
	left := 0
	for i, v := range nums {
		if left == sum-v {
			return i
		} else {
			sum -= v
			left += v
		}
	}
	return -1
}
